package com.itheima.web.controller;

import com.itheima.util.OssUtil;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
@CrossOrigin(value = "{http://127.0.0.1:81,http://127.0.0.1:82}")
@RestController
public class UploadFileController {
    @PostMapping("/image/upload")
    @ResponseBody
    public String upload(MultipartFile uploadFile) throws IOException {
        //调用工具类，返回上传的图片地址
        String url = OssUtil.upload(uploadFile.getOriginalFilename(), uploadFile.getResource().getInputStream());
        return url;
    }
}
